
function Person(name) {
    this.name=name;
    this.sum=function () {
        console.log(this.name);
    };
    this.colors=[1,2]
}
Person.prototype.age=10;
//1.原型链继承
function Per() {
    this.name='Per';
}
Per.prototype=new Person();//新实例的原型等于父类的实例
var per1=new Per();
per1.colors.push(3);
console.log(per1.colors);
var per2=new Per();
console.log(per2.colors);
//2.构造函数继承
function Con() {
    Person.call(this,'jer');
};
var con1=new Con();
console.log(con1.name);
console.log(con1.colors);
//3.组合继承
function SubType(name) {
    Person.call(this,name);
}
SubType.prototype=new Person;
var sub=new SubType('gar');
console.log(sub.name);
console.log(sub.age);
//原型式继承
function content(obj) {
    function F() {}
        F.prototype=obj;//继承了传入的参数
     return new F();//返回函数的对象
}
 var sup=new Person();
var sup1=content(sup);
console.log(sup1.age);